import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';

import "../app.dart";
import '../pages/home/home.dart';
import "./route_item.dart";

class RouteNames {
  static const rootPage = "/";
  static const homepage = "/home";
}

final List<RouteItem> _routes = [
  // 根页面
  RouteItem(
    path: RouteNames.rootPage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return const App();
      },
    ),
  ),
  // 主页
  RouteItem(
    path: RouteNames.homepage,
    handler: Handler(
      handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
        return const HomePage();
      },
    ),
  ),
];

FluroRouter router = FluroRouter();

void configureRoutes() {
  for (var index = 0; index < _routes.length; index++) {
    final item = _routes[index];
    router.define(item.path, handler: item.handler);
  }
}
